<?php
/**
 * @copyright meila.com
 * @author shaopu@
 * @name 检测登录邮件是否可用
 * @param 
 *         $email = 作用
 * 
 * 
 */
include('../../__global.php');
include(SERVER_ROOT_PATH.'/include/config/dataRule/ml_datarule_user.php');

class aj_checkEmailAvailable extends ml_controller 
{
    private $email;
    private $arrAlert = array(
        'format' => 'format_err',
        'len' => 'len',
        'exists' => 'ex',
    );
    function initParam()
    {
        $this->email = $this->input('email','G');
    }
    /**
     * @develop_template
     * 检查参数合法性
     */
    function checkParam()
    {
        $this->check_referer();
        if(filter_var($this->email , FILTER_VALIDATE_EMAIL) == false)
            $this->api_output(ML_RCODE_PARAM ,'', $this->arrAlert['format']);
            
        $len = strlen($this->email);
        if($len < ML_DATARULE_USER_EMAIL_MINLEN || $len > ML_DATARULE_USER_EMAIL_MAXLEN)
            $this->api_output(ML_RCODE_PARAM , '' , $this->arrAlert['len']);
        
        //关键字
    }
    /**
     * @develop_template
     * 核心业务逻辑
     */
    function main()
    {
        $oAccount = new ml_model_dbUserAccount();
        $rs = $oAccount->isEmailExists($this->email , $isExists);
        if(!$rs)
            $this->api_output(ML_RCODE_BUSY , '' , ML_RMESSAGE_BUSY);
        
        if($isExists)
            $this->api_output(ML_RCODE_SUCC , array('result'=>false));
        else 
            $this->api_output(ML_RCODE_SUCC , array('result'=>true));
    }
}

new aj_checkEmailAvailable();
?>